#ifndef QLSLANGUAGEMANAGER_H
#define QLSLANGUAGEMANAGER_H

#include <QObject>
#include <QMutex>
#include <QString>
#include <QStringList>
#include <QTranslator>

#include "dllQLsLanguagesManager_global.h"

class DLLQLSLANGUAGESMANAGER_EXPORT QLsLanguagesManager : public QObject
{
	Q_OBJECT
public:
	explicit QLsLanguagesManager(QObject *parent = nullptr);

	/* 唯一实例 */
	static QLsLanguagesManager &GetInstance();
	/* 销毁实例 */
	static void DestroyInstance();

	/* 刷新本地语言包 */
	void RefreshLocalLangPacks();
	/* 加载语言包
	 * 默认语言包文件名为 langPackName.qm
	 */
	bool LoadLangPack(const QString &langPackName);
	/* 获取可用语言包列表 */
	QStringList GetLangPacks() const;
	/* 获取当前语言包 */
	QString GetCurrentLangPack() const;

private:
	QStringList m_langPacksList;				/* 可用语言包列表 */
	QString m_curLangPack;						/* 当前语言包名 */
	QTranslator *m_curTranslator;				/* 当前语言包 */

	/* instance */
	static QMutex m_instanceMutex;
	static QLsLanguagesManager *m_instance;
};

#endif // QLSLANGUAGEMANAGER_H
